/*
 *    Copyright (c) 2018-2025, boss All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the boss developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: boss
 */

package com.hopes.bizz.risk.transfer.bean.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.hopes.bizz.risk.transfer.constant.RiskRequestType;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.common.entity.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 风险数据对接错误日志
 *
 * @author pig
 * @date 2024-02-02 10:44:14
 */
@Data
@TableName("risk_transfer_error_log")
@EqualsAndHashCode(callSuper = true)
@Schema(description = "风险数据对接错误日志")
public class RiskTransferErrorLogEntity extends BaseEntity {

    private static final long serialVersionUID = 1L;


    /**
     * id
     */
    @TableId(type = IdType.ASSIGN_ID)
    @Schema(description = "id")
    private Long id;

    /**
     * 错误id
     */
    @Schema(description = "错误id")
    private String errorId;

    /**
     * 业务id
     */
    @Schema(description = "错误id")
    private String busId;

    /**
     * 批次ID
     */
    @Schema(description = "批次ID")
    private String batchId;

    /**
     * 请求类型
     */
    @Schema(description = "请求类型")
    private Integer requestType;

    /**
     * 企业编码
     */
    @Schema(description = "企业编码")
    private String companyCode;

    /**
     * 失败原因
     */
    @Schema(description = "失败原因")
    private String failReason;

    /**
     * 解密后数据
     */
    @Schema(description = "解密后数据")
    private String receiveData;

    /**
     * 接收结果产生时间
     */
    @Schema(description = "接收结果产生时间")
    private LocalDateTime resultTime;

    /**
     * orgId
     */
    @Schema(description = "orgId")
    private Long orgId;


    public String getRequestTypeStr() {
        RiskRequestType riskRequestTypeEnum = RiskRequestType.getRiskRequestTypeByCode(requestType);
        if (Objects.nonNull(riskRequestTypeEnum)) {
            return riskRequestTypeEnum.getName();
        }
        return null;
    }

    public String getOrgIdStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_company, orgId);
    }
}